import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    status: false,
    hasLogin: false,
    userInfo: {},
    links: [],
  },
  mutations: {
    status: (state, data) => {
      state.status = data;
    },
    hasLogin: (state, data) => {
      state.hasLogin = data;
    },
    userInfo: (state, data) => {
      state.userInfo = data || {};
    },
    links: (state, data) => {
      state.links = data || [];
    },
  },
  actions: {
    getUserInfo: (context) => {
      context.commit("userInfo", { nickName: "东明" });
    },
    logout: (context) => {
      context.commit("userInfo", null);
      context.commit("hasLogin", false);
      context.commit("links", null);
    },
  },
});
